package interview.springboot.controller;

import interview.springboot.mybatis.entity.Student;
import interview.springboot.mybatis.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class MybatisController {


    @Autowired
    private StudentMapper studentMapper;

    @RequestMapping("/student/listAll")
    public List<Student> listAll() {
        return studentMapper.listAll();
    }

    @RequestMapping("/student/listAllMapByAssociation")
    public List<Student> listAllMapByAssociation() {
        return studentMapper.listAllMapByAssociation();
    }

    @RequestMapping("/student/listAllMapByLazyLoading")
    public List<Student> listAllMapByLazyLoading() {
        List<Student> students = studentMapper.listAllMapByLazyLoading();

        students.get(0).getClazz();
        students.get(0).getClazz().getHeaderTeacher();
        return null;
    }
}
